home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LTP_RenderCircle.c < prev    next >
C/C++ Source or Header  |  1996-03-18  |  1KB  |  71 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #ifdef DO_TAPEDECK_KIND
  15. VOID
  16. LTP_RenderCircle(struct RastPort *RPort,LONG Left,LONG Top,LONG Radius,LONG AspectX,LONG AspectY)
  17. {
  18.     LONG x = 0,y = Radius,Delta = 2 * (1 - Radius),delta,Limit = 0,Length;
  19.  
  20.     while(y >= Limit)
  21.     {
  22.         if(Delta < 0)
  23.         {
  24.             delta = 2 * Delta + 2 * y - 1;
  25.  
  26.             if(delta > 0)
  27.             {
  28.                 x = x + 1;
  29.                 y = y - 1;
  30.                 Delta = Delta + 2 * x - 2 * y + 2;
  31.             }
  32.             else
  33.             {
  34.                 x = x + 1;
  35.                 Delta = Delta + 2 * x + 1;
  36.             }
  37.         }
  38.         else
  39.         {
  40.             if(Delta > 0)
  41.             {
  42.                 delta = 2 * Delta - 2 * x - 1;
  43.  
  44.                 if(delta > 0)
  45.                 {
  46.                     y = y - 1;
  47.                     Delta = Delta - 2 * y + 1;
  48.                 }
  49.                 else
  50.                 {
  51.                     x = x + 1;
  52.                     y = y - 1;
  53.                     Delta = Delta + 2 * x - 2 * y + 2;
  54.                 }
  55.             }
  56.             else
  57.             {
  58.                 x = x + 1;
  59.                 y = y - 1;
  60.                 Delta = Delta + 2 * x - 2 * y + 2;
  61.             }
  62.         }
  63.  
  64.         Length = (x * AspectY) / AspectX;
  65.  
  66.         LTP_DrawLine(RPort,Left - Length,Top + y - 1,Left + Length - 1,Top + y - 1);
  67.         LTP_DrawLine(RPort,Left - Length,Top - y,Left + Length - 1,Top - y);
  68.     }
  69. }
  70. #endif    /* DO_TAPEDECK_KIND */
  71.